package com.azxcrm.project.system.basic.service;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.azxcrm.common.utils.StringUtils;
import com.azxcrm.common.utils.security.ShiroUtils;
import com.azxcrm.project.system.basic.dao.ICustomerClueCommunicationDao;
import com.azxcrm.project.system.basic.domain.CustomerClueCommunication;
import com.azxcrm.project.system.basic.service.ICustomerClueCommunicationService;

/**
 * 客户线索沟通记录 服务层实现
 * 
 * @author Dustyone
 * @date 2018-09-13
 */
@Service
public class CustomerClueCommunicationServiceImpl implements ICustomerClueCommunicationService 
{
	@Autowired
	private ICustomerClueCommunicationDao customerClueCommunicationDao;
	
	/**
     * 查询客户线索沟通记录信息
     * 
     * @param recordId 客户线索沟通记录ID
     * @return 客户线索沟通记录信息
     */
	 @Override
	public CustomerClueCommunication selectCustomerClueCommunicationById(Integer recordId)
	{
	    return customerClueCommunicationDao.selectCustomerClueCommunicationById(recordId);
	}
	
	/**
     * 查询客户线索沟通记录列表
     * 
     * @param customerClueCommunication 客户线索沟通记录信息
     * @return 客户线索沟通记录集合
     */
	 @Override
	public List<CustomerClueCommunication> selectCustomerClueCommunicationList(CustomerClueCommunication customerClueCommunication)
	{
	    return customerClueCommunicationDao.selectCustomerClueCommunicationList(customerClueCommunication);
	}
	
    /**
     * 新增客户线索沟通记录
     * 
     * @param customerClueCommunication 客户线索沟通记录信息
     * @return 结果
     */
	 @Override
	public int insertCustomerClueCommunication(CustomerClueCommunication customerClueCommunication)
	{
	    return customerClueCommunicationDao.insertCustomerClueCommunication(customerClueCommunication);
	}
	
	/**
     * 修改客户线索沟通记录
     * 
     * @param customerClueCommunication 客户线索沟通记录信息
     * @return 结果
     */
	 @Override
	public int updateCustomerClueCommunication(CustomerClueCommunication customerClueCommunication)
	{
	    return customerClueCommunicationDao.updateCustomerClueCommunication(customerClueCommunication);
	}
	
	/**
     * 保存客户线索沟通记录
     * 
     * @param customerClueCommunication 客户线索沟通记录信息
     * @return 结果
     */
	 @Override
	public int saveCustomerClueCommunication(CustomerClueCommunication customerClueCommunication)
	{
	    Integer recordId = customerClueCommunication.getRecordId();
		int rows = 0;
		if (StringUtils.isNotNull(recordId))
        {
		    rows = customerClueCommunicationDao.updateCustomerClueCommunication(customerClueCommunication);
		}
		else
        {
			customerClueCommunication.setCreateBy(ShiroUtils.getLoginName());
		    rows = customerClueCommunicationDao.insertCustomerClueCommunication(customerClueCommunication);
		}
		return rows;
	}
	
	/**
     * 删除客户线索沟通记录信息
     * 
     * @param recordId 客户线索沟通记录ID
     * @return 结果
     */
	 @Override
	public int deleteCustomerClueCommunicationById(Integer recordId)
	{
	    return customerClueCommunicationDao.deleteCustomerClueCommunicationById(recordId);
	}
	
	/**
     * 批量删除客户线索沟通记录对象
     * 
     * @param recordIds 需要删除的数据ID
     * @return 结果
     */
	 @Override
	public int batchDeleteCustomerClueCommunication(Integer[] recordIds)
	{
		return customerClueCommunicationDao.batchDeleteCustomerClueCommunication(recordIds);
	}

	 /**
     * 查询客户线索沟通记录信息
     * 
     * @param recordId 客户线索ID
     * @return 客户线索沟通记录信息
     */
	@Override
	public CustomerClueCommunication selectCustomerClueCommunicationByClueId(Integer clueId) {
		return customerClueCommunicationDao.selectCustomerClueCommunicationByClueId(clueId);
	}
	
}
